package com.ydh.company.controller;


import com.ydh.company.dto.ResponseData;
import com.ydh.company.dto.ResultData;
import com.ydh.company.pojo.Condition;
import com.ydh.company.pojo.User;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@Api(tags = "登录注册测试API  2个接口")
@RequestMapping("/login")
public class LoginController {

    @PostMapping("/do")
    @ApiOperation(value = "登录测试接口", notes = "json传递用户名和密码")
    public ResultData login(@RequestBody User user) {
        User user1 = new User();
        user1.setUserId("1");
        user1.setUserAccount("2");
        user1.setJobId("1");
        user1.setTel("5525536655");
        if (user.getUsername().equals("admin")&&user.getPassword().equals("123123")) {
            return ResponseData.success("登录成功",user1);
        }
        return ResponseData.error(400,"登录失败");
    }

    @PostMapping("/register")
    @ApiOperation(value = "注册测试接口",notes = "用户输入基本信息进行账号注册")
    public ResultData register(@RequestBody User user){

        if (user.getUsername().equals("")) {
            return ResponseData.success("注册成功",null);
        }
        return ResponseData.error(400,"注册失败");
    }
}

